import Vue from 'vue'
import Vuex from 'vuex'
import VuexPersist from 'vuex-persist'

Vue.use(Vuex)

const state = {
  token: ''
};

const mutations = {
  setToken (state, token) {
    state.token = token;
  }
}

const vuexPersist = new VuexPersist({
  storage: window.localStorage,
  reducer: state => ({
    token: state.token
  })
})

export default new Vuex.Store({
  state,
  mutations,
  plugins: [vuexPersist.plugin]
})
